<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>院前急救云平台</title>
    <%String path = request.getContextPath(); %>
    <link href="<%=path%>/css/login.css" rel="stylesheet" type="text/css" />
   <script type="text/javascript" src="<%=path%>/js/jquery.js"></script>
    <script src="<%=path%>/js/md5-min.js"></script>
    <script type="text/javascript">
        $(document).keydown(function (event) {
            if (event.keyCode == "13") {
                $("#btnlogin").click();
            }
        });
        $(function () {
            $("input:eq(0)").focus();
            $("#btnlogin").click(function () {
                var userName = $("input[name='UserName']").val();
                var password = $("input[name='Password']").val();
                var data = {
                      "id": 1,
                       "platform": "web",
                       "uid": "",
                       "parameter": {
                        "loginname": userName,
                        "pwd": password
                        }
                   
                };

                if ($.trim(userName)!= "" && $.trim(password)!= "") {
                        $.ajax({
                            url: "<%=path%>/user/login.htm",
                            data: JSON.stringify(data),
                            type : "POST",
                            contentType:"application/json",
                            dataType: "json",
                            success: function (result) {
                            	/* alert("返回了数据。。。。。。。"); */
                                var data = $.parseJSON(result);
                                var status = data.status;
                                if (status== "100000") {
                                 //根据用户类型，跳转到不同的页面
                                  if (data.result.type=="1") {
                                       window.parent.location.href = 
                                    "<%=path%>/login/show.htm";
                                   }else if (data.result.type=="2"){
                                    window.parent.location.href = 
                                    "<%=path%>/login/main.htm";
                                  }
                                
                                }
                                else {
                                    $("#loginmsg").text("用户名或密码错误！");
                                    $("input[type='text']").val("");
                                    $("input[type='password']").val("");
                                }
                            }
                        });
                    }
                
                else {
                    $("#loginmsg").text("用户名或密码不能为空！");
                    ChangeValidateCode();
                }
            });
            $("#btnreset").click(function () {
                $("input[name='UserName']").val("");
                $("input[name='Password']").val("");
                $("#loginmsg").text("");
                ChangeValidateCode();
            });
            $("#validateCode").click(function () {
                ChangeValidateCode();
            });
        });
        //获取验证码
        function ChangeValidateCode() {
            $("#validateCode").attr("src", "/Home/ValidateCode");
        }
    </script>
</head>

<body>
    <div class="main-login">
        <div class="login-logo">
        </div>
        <div class="login-content">
            <div class="login-info">
                <span class="user">&nbsp;</span>
                <input name="UserName" type="text" autocomplete="off" maxlength="20" placeholder="请输入用户名" value="" class="login-input" />
            </div>
            <div class="login-info">
                <span class="pwd">&nbsp;</span>
                <input name="Password" type="password" autocomplete="off" maxlength="20" placeholder="请输入密码" value="" class="login-input" />
            </div>
           <!--  <div class="login-info">
                <span class="user">&nbsp;</span>
                <input name="ValidateCode" style="width:238px;" type="text" autocomplete="off" maxlength="20" placeholder="请输入验证码" value="" class="login-input" />
                <img id="validateCode" src="/Home/ValidateCode" style="width:100px; height:40px; float:right;">
            </div> -->
            <div id="loginmsg" style="margin-top:5px;">
            </div>
            <div class="login-oper" style="margin-top:5px;">
                <input id="btnlogin" class="login-btn" type="button" value="登　录" />
                <input id="btnreset" class="login-reset" type="button" value="重　置" />
            </div>
        </div>
    </div>
    <div id="login-bottom">
        &copy;2016 北京华普东方科技有限公司
    </div>
</body>
</html>
